package mac.runtimeChecker.medlParser;

import mac.types.parserTypes.*;

public class ASTExpression extends SimpleNode {
  static final int VARIABLE = 0;
  static final int CAST = 1;
  static final int METHOD = 2;
  static final int ADD = 3;
  static final int SUBTRACT = 4;
  static final int MULTIPLY = 5;
  static final int DIVIDE = 6;
  static final int MOD = 7;
  static final int PLUS = 8;
  static final int MINUS = 9;
  static final int TIME = 10;
  static final int VALUE = 11;
  static final int PARENTHESIS = 12;
  static final int CONSTANT = 13;
  static final int LSHIFT = 14;
  static final int RSHIFT = 15;
  static final int ARRAY = 16;
  static final int TYPE = 17;
  static final int ASSIGNMENT = 18;
  static final int GUARD = 19;
  static final int IFCOND = 20;

  protected int type;
  protected String name;
  protected Object value;
  protected Object oldValue;

  ASTExpression(int id) {
    super(id);
  }

  public int getType() {
    return type;
  }
  public String getName() {
    return name;
  }



  public Object getValue() {
    return value;
  }
  public Object getOldValue() {
    return oldValue;
  }

  public void setType(int t) {
    type = t;
  }
  public void setName(String n) {
    name = n;
  }
  public void setValue(Object v) {
    value = v;
  }
  public String toString() {
    String s= null;
    String s2= null;
    Object realValue = null;
    SymtabEntry se = null;

    switch (type) {
      case VARIABLE: s =  "Expression: variable "+name;break;
      case CAST: s =  "Expression: type cast";break;
      case METHOD: s =  "Expression: method";break;
      case ADD: s =  "Expression: addition";break;
      case SUBTRACT: s =  "Expression: subtraction";break;
      case MULTIPLY: s =  "Expression: multiplication";break;
      case DIVIDE: s =  "Expression: division";break;
      case MOD: s =  "Expression: mod";break;
      case PLUS: s =  "Expression: plus";break;
      case MINUS: s =  "Expression: minus";break;
      case TIME: s =  "Expression: time";break;
      case VALUE: s =  "Expression: value";break;
      case PARENTHESIS: s =  "Expression: parenthesis";break;
      case CONSTANT: s =  "Expression: constant";break;
      case LSHIFT: s =  "Expression: left shift";break;
      case RSHIFT: s =  "Expression: right shift";break;
      case ARRAY: s =  "Expression: array";break;
      case TYPE: s =  "Expression: type";break;
      case ASSIGNMENT: s = "Expression: assignment"; break;
      case GUARD: s = "Expression: guard"; break;
      case IFCOND: s = "Expression: if condition"; break;
      default: s =  "Expression: error";break;
    }
    return s;

/*      if(value instanceof SymtabEntry) {
	  se = (SymtabEntry)value;
	  if( ((String)(se.getType())).equals("_macType")) {
	      realValue = ((Node)(se.getValue())).getValue(); 
	  } else {
	      realValue = se.getValue();
	  }
      } else {
	  realValue = value;
      }

      return s + "(name:"+ name + ",value:" 
	    + realValue + ",mark:" + mark +")" ; */

  }
/*  public boolean isUpdated() { 
      if(type != VARIABLE) {
	  System.err.println("isUpdated must not be called at " + this);
	  return  false;
      } else {
	  return ((SymtabEntry)getValue()).isUpdated();
      }
  } */
      
}
